home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWZone.z / RWZone
Encoding:
Text File  |  1998-10-30  |  11.1 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))                                                      RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWZone - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <time.h>
  13.  
  14.  
  15.  
  16.               #include <rw/zone.h>
  17.           ((((aaaabbbbssssttttrrrraaaacccctttt bbbbaaaasssseeee ccccllllaaaassssssss))))
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      RRRRWWWWZZZZoooonnnneeee is an abstract base class.  It defines an interface for time zone
  24.      issues such as whether or not daylight-saving time is in use, the names
  25.      and offsets from UTC (also known as GMT) for both standard and daylight-
  26.      saving times, and the start and stop dates for daylight-saving time, if
  27.      used.  Note that because it is an aaaabbbbssssttttrrrraaaacccctttt base class, there is no way to
  28.      actually enforce these goals -- the description here is merely the model
  29.      of how a class derived from RRRRWWWWZZZZoooonnnneeee should act.  Most programs interact
  30.      with RRRRWWWWZZZZoooonnnneeee only by passing an RRRRWWWWZZZZoooonnnneeee reference to an RRRRWWWWTTTTiiiimmmmeeee or RRRRWWWWDDDDaaaatttteeee
  31.      member function that expects one.  RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee is an implementation of
  32.      the abstract RRRRWWWWZZZZoooonnnneeee interface sufficient to represent U.S. daylight-
  33.      saving time rules.  Three instances of RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee are initialized from
  34.      the global environment at program startup to represent local, standard,
  35.      and universal time.  They are available via calls to the static member
  36.      functions RRRRWWWWZZZZoooonnnneeee::::::::llllooooccccaaaallll(((()))), RRRRWWWWZZZZoooonnnneeee::::::::ssssttttaaaannnnddddaaaarrrrdddd(((()))), and RRRRWWWWZZZZoooonnnneeee::::::::uuuuttttcccc(((()))),
  37.      respectively.  See the class RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee for details.
  38.  
  39. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  40.      None
  41.  
  42. EEEExxxxaaaammmmpppplllleeee
  43.               #include <rw/zone.h>
  44.           #include <rw/rwtime.h>
  45.           #include <rw/rstream.h>
  46.           main(){
  47.            RWTime now;
  48.            cout << now.asString(' ', RWZone::local()) << endl;
  49.            cout << now.asString("%x %X", RWZone::utc()) << endl;
  50.            return 0;
  51.           }
  52.  
  53. EEEEnnnnuuuummmmeeeerrrraaaattttiiiioooonnnnssss
  54.               enum DstRule { NoDST, NoAm, WeEu };
  55.  
  56.  
  57.      Used by the static member function ddddssssttttRRRRuuuulllleeee(((()))), described below, and by
  58.      constructors for classes derived from RRRRWWWWZZZZoooonnnneeee.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))                                                      RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               enum StdZone {
  75.             NewZealand = -12,     CarolineIslands,     MarianaIslands,
  76.             Japan,                China,               Java,
  77.             Kazakh,               Pakistan,            CaspianSea,
  78.             Ukraine,              Nile,                Europe,
  79.             Greenwich,            Azores,              Oscar,
  80.             Greenland,            Atlantic,            USEastern,
  81.             USCentral,            USMountain,          USPacific,
  82.             Yukon,                Hawaii,              Bering
  83.           };
  84.  
  85.  
  86.      SSSSttttddddZZZZoooonnnneeee is provided to name the standard time zones.  Its values are
  87.      intended to be passed to constructors of classes derived from RRRRWWWWZZZZoooonnnneeee.
  88.  
  89. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  90.               virtual int
  91.           ttttiiiimmmmeeeeZZZZoooonnnneeeeOOOOffffffffsssseeeetttt() const = 0;
  92.  
  93.  
  94.      Returns the number of seconds west of UTC for standard time in this zone.
  95.      The number is negative for zones east of Greenwich, England.
  96.  
  97.               virtual int
  98.           aaaallllttttZZZZoooonnnneeeeOOOOffffffffsssseeeetttt() const = 0;
  99.  
  100.  
  101.      Returns the number of seconds west of UTC for daylight-saving time in
  102.      this zone.
  103.  
  104.               virtual RWBoolean
  105.           ddddaaaayyyylllliiiigggghhhhttttOOOObbbbsssseeeerrrrvvvveeeedddd() const = 0;
  106.  
  107.  
  108.      Returns TTTTRRRRUUUUEEEE if daylight-saving time is observed for this zone.
  109.  
  110.               virtual RWBoolean
  111.           iiiissssDDDDaaaayyyylllliiiigggghhhhtttt(const struct tm* tspec) const = 0;
  112.  
  113.  
  114.      Returns TTTTRRRRUUUUEEEE if the time and date represented in the ssssttttrrrruuuucccctttt ttttmmmm argument
  115.      is in the range of daylight-saving time for this zone.  The elements of
  116.      the ttttmmmm argument must all be self-consistent; in particular, the ttttmmmm____wwwwddddaaaayyyy
  117.      member must agree with the ttttmmmm____yyyyeeeeaaaarrrr, ttttmmmm____mmmmoooonnnn, and ttttmmmm____ddddaaaayyyy members.
  118.  
  119.               virtual void
  120.           ggggeeeettttBBBBeeeeggggiiiinnnnDDDDaaaayyyylllliiiigggghhhhtttt(struct tm*) const = 0;
  121.           virtual void
  122.           ggggeeeettttEEEEnnnnddddDDDDaaaayyyylllliiiigggghhhhtttt  (struct tm*) const = 0;
  123.  
  124.  
  125.      Return with the ssssttttrrrruuuucccctttt ttttmmmm argument set to the local time that daylight-
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))                                                      RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      saving time begins, or ends, for the year indicated by the ttttmmmm____yyyyeeeeaaaarrrr member
  141.      passed in.  If daylight-saving time is not observed, the ssssttttrrrruuuucccctttt ttttmmmm
  142.      members are all set to a negative value.  Note that in the southern
  143.      hemisphere, daylight-saving time ends at an earlier date than it begins.
  144.  
  145.               virtual RWCString
  146.           ttttiiiimmmmeeeeZZZZoooonnnneeeeNNNNaaaammmmeeee() const = 0;
  147.           virtual RWCString
  148.           aaaallllttttZZZZoooonnnneeeeNNNNaaaammmmeeee() const = 0;
  149.  
  150.  
  151.      Return the name of, respectively, the standard and daylight-saving time
  152.      zones represented, such as """"PPPPSSSSTTTT"""" and """"PPPPDDDDTTTT"""".  Note that the current date
  153.      and time have no effect on the return values of these functions.
  154.  
  155. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  156.               static const RWZone&
  157.           llllooooccccaaaallll();
  158.  
  159.  
  160.      Returns a reference to an RRRRWWWWZZZZoooonnnneeee representing local time.  By default
  161.      this will be an instance of RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee created with offsets and zone
  162.      names from the operating system, with U.S. rules for daylight-saving time
  163.      if observed.  This is used as the default argument value for RRRRWWWWDDDDaaaatttteeee and
  164.      RRRRWWWWTTTTiiiimmmmeeee functions that take an RRRRWWWWZZZZoooonnnneeee.
  165.  
  166.               static const RWZone&
  167.           ssssttttaaaannnnddddaaaarrrrdddd();
  168.  
  169.  
  170.      Returns a reference to an RRRRWWWWZZZZoooonnnneeee representing standard local time, with
  171.      no daylight-saving time corrections.  By default this is an instance of
  172.      RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee with offset and zone name from the operating system.
  173.  
  174.               static const RWZone&
  175.           uuuuttttcccc();
  176.  
  177.  
  178.      Returns a reference to an RRRRWWWWZZZZoooonnnneeee representing UTC (GMT) universal time.
  179.  
  180.               static const RWZone*
  181.           llllooooccccaaaallll(const RWZone*);
  182.           static const RWZone*
  183.           ssssttttaaaannnnddddaaaarrrrdddd(const RWZone*);
  184.  
  185.  
  186.      These functions allow the values returned by the other functions above to
  187.      be set.  Each returns the previous value.
  188.  
  189.               static constRWDaylightRule*
  190.           ddddssssttttRRRRuuuulllleeee(DstRule rule = NoAm);
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))                                                      RRRRWWWWZZZZoooonnnneeee((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Returns one of the built-in daylight-saving time rules according to rrrruuuulllleeee.
  207.      Function ddddssssttttRRRRuuuulllleeee(((()))) is provided for convenience in constructing
  208.      RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee instances for time zones in which common daylight-saving
  209.      time rules are obeyed.  Currently two such rule systems are provided,
  210.      NNNNooooAAAAmmmm for the U.S.A. and Canada, and WWWWeeeeEEEEuuuu for most of Western Europe
  211.      (excluding the U.K.).  See RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee for more details.  If DDDDssssttttRRRRuuuulllleeee
  212.      NNNNooooDDDDSSSSTTTT is given, then 0000 is returned. The result of calling ddddssssttttRRRRuuuulllleeee(((()))) is
  213.      normally passed to the RRRRWWWWZZZZoooonnnneeeeSSSSiiiimmmmpppplllleeee constructor.
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.